home *** CD-ROM | disk | FTP | other *** search
- Path: news.halcyon.com!usenet
- From: normanb@halcyon.com (Norm Bryar)
- Newsgroups: comp.lang.c++
- Subject: Re: Default values
- Date: Sat, 20 Apr 1996 15:27:59 GMT
- Organization: Northwest Nexus Inc.
- Message-ID: <4lavog$5m6@news.halcyon.com>
- References: <26418@829921816>
- NNTP-Posting-Host: blv-pm2-ip16.halcyon.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- "dan j" <djacobso@cs.indiana.edu> wrote:
-
- >Is it somehow possible to use a class member variable as a default
- >value to a member function? When, if ever, can variables serve as
- >default values? For instance,
-
- >class tree {
- > tree_node * root;
-
- >public:
- > ...
- > foo(tree_node * ptr = root) { (recursive); }
- > ...
- >};
-
- >g++ (SunOS) says 'root' is not defined in this scope.
-
- >A special function foo2() called with 'root' serves the purpose:
-
- > foo(tree_node * ptr) { (recursive); }
- > foo2(void) { foo(root); }
-
- >But what is a better way to handle this?
-
-
- >dan j
-
- Would your implementation suffer if the default value was NULL and the
- implementation chooses root if ptr == NULL?
-
- --Norm
-
-